class Solution(object):
    def countLetters(self, s):
        """
        :type s: str
        :rtype: int
        """
        left_index = 0
        right_index = 0
        n = len(s)
        value = 0
        while right_index < n:
            if s[right_index] == s[left_index]:
                right_index += 1
            else:
                t = right_index - left_index
                value += t * (t + 1) // 2
                left_index = right_index
                right_index += 1
        t = right_index - left_index
        value += t * (t + 1) // 2
        return value